forked from llvm/llvm-project
-
Couldn't load subscription status.
- Fork 1
[GPU][AMD] Represent each lane on the GPU as a thread in lldb #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit modifies the way we represent threads in the AMDGPU plugin. Previously, we would represent each GPU *wave* as a thread, which matches the way it is done in rocgdb. Now, we represent each GPU *lane* as a thread, which is the design choice we made for lldb. The benefit of lanes-as-threads is to make the debugger representation match the programming model more closely. This is also the way the Nvidia plugin represents threads. As part of this change we add a new `WaveAMDGPU` class that represents a GPU wave. Each thread maintains a pointer to the wave it belongs to. This allows us to store common wave information in the wave object, and access it from any thread in the wave. We use a map to hold the currently active waves, which we retrieve from the dbgapi. This map is updated when a new wave is created, and when a wave is destroyed. The core of the logic is driven from the `UpdateThreads` function, which can be called by lldb-server or directly from the plugin. We call update threads when we receive a wave-stop event to refresh the thread list. To update the thread list we query the dbgapi for the currently active waves, and add any new waves to the map. We then iterate over the list of active waves and refresh the wave info for that wave. Finally, for any new waves we add the threads in the wave to the thread list and remove any threads that are now dead. We avoid rebuilding the thread list each time we update the waves because we want to keep the order of threads deterministic in the list and the dbgapi does not guarantee a consistent order when querying the active waves.
dmpots
commented
Oct 9, 2025
clayborg
requested changes
Oct 10, 2025
lldb/tools/lldb-server/Plugins/AMDGPU/LLDBServerPluginAMDGPU.cpp
Outdated
Show resolved
Hide resolved
clayborg
requested changes
Oct 13, 2025
clayborg
requested changes
Oct 15, 2025
lldb/tools/lldb-server/Plugins/AMDGPU/LLDBServerPluginAMDGPU.cpp
Outdated
Show resolved
Hide resolved
clayborg
approved these changes
Oct 16, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit modifies the way we represent threads in the AMDGPU plugin. Previously, we would represent each GPU wave as a thread, which matches the way it is done in rocgdb.
Now, we represent each GPU lane as a thread, which is the design choice we made for lldb. The benefit of lanes-as-threads is to make the debugger representation match the programming model more closely. This is also the way the Nvidia plugin represents threads.
As part of this change we add a new
WaveAMDGPUclass that represents a GPU wave. Each thread maintains a pointer to the wave it belongs to. This allows us to store common wave information in the wave object, and access it from any thread in the wave.We use a map to hold the currently active waves, which we retrieve from the dbgapi. This map is updated when a new wave is created, and when a wave is destroyed.
The core of the logic is driven from the
UpdateThreadsfunction, which can be called by lldb-server or directly from the plugin. We call update threads when we receive a wave-stop event to refresh the thread list.To update the thread list we query the dbgapi for the currently active waves, and add any new waves to the map. We then iterate over the list of active waves and refresh the wave info for that wave. Finally, for any new waves we add the threads in the wave to the thread list and remove any threads that are now dead. We avoid rebuilding the thread list each time we update the waves because we want to keep the order of threads deterministic in the list and the dbgapi does not guarantee a consistent order when querying the active waves.